﻿using BCDto.Location.Branches;
using BCDto.TMS.Agent.AgentBranchesConfig;
using BCService.TMS.Agent.AgentBranchesConfig;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace BCTMSRESTful.Controllers.DriverApp.AgentBranchesConfig
{
    /// <summary>
    /// 代理商网点配置
    /// </summary>
    [ApiExplorerSettings(GroupName = "DriverApp")]
    [Route("api/v1/DriverApp/[controller]")]
    public class AgentBranchesConfigController : DriverAppBaseController
    {
        private readonly IAgentBranchesConfigService agentBranchesConfigService;

        public AgentBranchesConfigController(IAgentBranchesConfigService agentBranchesConfigService)
        {
            this.agentBranchesConfigService = agentBranchesConfigService;
        }

        #region List 
        /// <summary>
        /// 查询附近代理商网点配置
        /// </summary>
        /// <param name="longitude">经度</param>
        /// <param name="latitude">纬度</param>
        /// <param name="maxDistance">最大距离</param>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(IEnumerable<BranchesLocationNearDto>), 200)]
        public IActionResult List([FromQuery(Name = "longitude")] double longitude,
            [FromQuery(Name = "latitude")] double latitude,
            [FromQuery(Name = "max_distance")] int maxDistance)
        {
            var result = agentBranchesConfigService.GetList(longitude, latitude, maxDistance);
            return this.Ok(result);
        }
        #endregion
    }
}
